<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <form action="">
        <select name="" id="city">
            <!-- multiple允许多选，按住ctrl多选 -->
            <option value="chengdu">成都</option>
            <option value="chongqing">重庆</option>
            <option value="shanghai">上海</option>
            <option value="hangzhou">杭州</option>
        </select>
        <input type="button" value="提交" id="btn">
    </form>

    <script>
        let city = document.getElementById('city');
        console.log(city.options);//获取所有option

        let btn = document.getElementById('btn');
        btn.onclick = function () {
            
            // console.log(city.selectedIndex);//获取选中option的下标
            // console.log(city.value);//获取选中option得value值
            // console.log(city.selectedOptions);//获取选中的所有option

            //创建option
            // let newOption = new Option('香港', 'xianggang');
            // console.log(newOption);
            // //添加
            // city.options.add(newOption)
            //删除  传入删除option得下标
            // city.options.remove(1);

            //修改
            city.options[1].value='CQ';
            city.options[1].text='chongqing';
        }

    </script>

</body>

</html>